package com.hle;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;

import com.hle.tools.Integers;
import com.sun.source.tree.AnnotationTree;
import com.hle.sort.CountingSort;
import com.hle.sort.RadixSort;
import com.hle.sort.RadixSort1;
import com.hle.sort.Sort;
import com.hle.sort.cmp.BubbleSort1;
import com.hle.sort.cmp.BubbleSort2;
import com.hle.sort.cmp.BubbleSort3;
import com.hle.sort.cmp.HeapSort;
import com.hle.sort.cmp.InsertionSort1;
import com.hle.sort.cmp.InsertionSort2;
import com.hle.sort.cmp.InsertionSort3;
import com.hle.sort.cmp.MergeSort;
import com.hle.sort.cmp.QuickSort;
import com.hle.sort.cmp.SectionSort;
import com.hle.sort.cmp.ShellSort;
import com.hle.tools.Asserts;
@SuppressWarnings({"rawtypes","unchecked"})
public class Main {
	
	static void testSorts(Integer[] array, Sort... sorts) {
		for (Sort sort : sorts) {
			Integer[] newArray = Integers.copy(array);
			sort.sort(newArray);
			Asserts.test(Integers.isAscOrder(newArray));
		}
		Arrays.sort(sorts);
		
		for (Sort sort : sorts) {
			System.out.println(sort);
		}
	}

	public static void main(String[] args) {
//		Integer[] array  = Integers.random(100000, 50, 100);
		Integer[] array = {7,3,5,8,6,7,4,5};
		testSorts(array, 
//				new HeapSort(), 
//				new BubbleSort3(),
//				new SectionSort(),
//				new InsertionSort1(),
//				new InsertionSort2(),
//				new InsertionSort3(),
//				new MergeSort(),
//				new QuickSort(),
//				new ShellSort(),
//				new CountingSort(),
//				new RadixSort(),
				new RadixSort1()
				);
		
//		Integers.println(array);
//
//		Asserts.test(BinarySearch.search(array, 5) == 2);
//		Asserts.test(BinarySearch.search(array, 1) == 0);
//		Asserts.test(BinarySearch.search(array, 15) == 7);
//		Asserts.test(BinarySearch.search(array, 8) == 5);
	}
}


